package task

import event.ReplenishListChangedEvent
import ext.log
import manager.HttpRequestManager
import manager.ReplenishManager
import org.greenrobot.eventbus.EventBus
import org.json.JSONObject


/**
 * 获取补货清单
 */
class ReplenishListTask : Runnable {
    override fun run() {
        try {
            val ret = HttpRequestManager.refreshReplenishList()
            log("---$ret")
            val json = JSONObject(ret)
            ReplenishManager.onReplenishListResult(json)
        } catch (e: Exception) {
            e.printStackTrace()
            EventBus.getDefault().post(ReplenishListChangedEvent(false))
        }
    }
}